import Vue from 'vue'
import Vuex from 'vuex'
import mutations from './mutations'
import actions from './actions'
import getters from './getters'
import moduleA from './modules/moduleA'

// 1.安装插件 
Vue.use(Vuex)

// 2.创建对象

const state = {
  // 保存状态
  counter: 10,
  students:[
    {id: 1, name: '张三', age: 17},
    {id: 2, name: '李四', age: 14},
    {id: 3, name: '王五', age: 21},
    {id: 4, name: '赵二', age: 35},
    {id: 5, name: '刘一', age: 61}
  ],
  info:{
    name: 'why',
    age: 18,
    height: 171
  }

}

const store = new Vuex.Store({
  // state: state,
  // mutations:mutations,
  // actions:actions,
  // getters: getters,

  // 增强写法
  state,
  mutations,
  actions,
  getters,
  modules: {
    // 分模块
    a: moduleA,

  }
})

// 3.导出store对象
export default store